package cn.tedu.yy.service.impl;

import cn.tedu.yy.mapper.ReservationMapper;
import cn.tedu.yy.pojo.dto.DemandDTO;
import cn.tedu.yy.pojo.dto.DemandQuery;
import cn.tedu.yy.pojo.entity.Demand;
import cn.tedu.yy.pojo.vo.DemandVO;
import cn.tedu.yy.service.ReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Slf4j
@Service
public class ReservationServiceImpl implements ReservationService {
    @Autowired(required=true)
    ReservationMapper reservationMapper;
    @Override
    public void saveyy(DemandDTO demandDTO) {
      log.debug("保存预约信息业务：demandDTO:{}", demandDTO);
        Demand demand = new Demand();
        BeanUtils.copyProperties(demandDTO, demand);
        if (demand.getUserId()==null){
            demand.setUserId(1);
            reservationMapper.insert(demand);
        }else {
        }
    }

    @Override
    public List<DemandVO> selectyy(DemandQuery demandQuery) {
        log.debug("查询预约信息业务：demandQuery:{}", demandQuery);
        demandQuery.setUserId(1);
        List<DemandVO> list = reservationMapper.selectyy(demandQuery);
        return list;
    }

    @Override
    public void deleteyy(Integer userId) {
        log.debug("删除预约信息业务：userId:{}", userId);
        reservationMapper.deleteyy(userId);
    }
}
